package com.z17.myapplication_a;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.z17.myapplication_a.ContentProvider.ContentProviderActivity;
import com.z17.myapplication_a.External.ExternalActivity;
import com.z17.myapplication_a.SharedPreference.SharedPreferenceActivity;
import com.z17.myapplication_a.internal.InternalActivity;
import com.z17.myapplication_a.sqlite.SqliteActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button internal, external, sqlite, sharedpreference, contentProvider;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }

    private void init() {
//        initView
        internal = (Button) findViewById(R.id.btn_internal);
        external = (Button) findViewById(R.id.btn_external);
        sqlite = (Button) findViewById(R.id.btn_sqlite);
        sharedpreference = (Button) findViewById(R.id.btn_preferences);
        contentProvider = (Button) findViewById(R.id.btn_sqlitecv);
//        initEvent
        internal.setOnClickListener(this);
        external.setOnClickListener(this);
        sqlite.setOnClickListener(this);
        sharedpreference.setOnClickListener(this);
        contentProvider.setOnClickListener(this);


    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_external:
                startActivity(new Intent(MainActivity.this, ExternalActivity.class));
                break;

            case R.id.btn_internal:
                startActivity(new Intent(MainActivity.this, InternalActivity.class));
                break;

            case R.id.btn_preferences:
                startActivity(new Intent(MainActivity.this, SharedPreferenceActivity.class));
                break;

            case R.id.btn_sqlite:
                startActivity(new Intent(MainActivity.this, SqliteActivity.class));
                break;

            case R.id.btn_sqlitecv:
                startActivity(new Intent(MainActivity.this, ContentProviderActivity.class));
                break;
        }
    }
}
